package com.example.mylibrary;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;


public class MyImageToast {
    Toast toast;

    public MyImageToast(Context context, String text, int draw) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.image_toast_view, null);
        TextView t = view.findViewById(R.id.toast_text);
        ImageView img = view.findViewById(R.id.toasting_img);
        img.setImageDrawable(context.getResources().getDrawable(draw));
        t.setText(text);
        if (toast != null) {
            toast.cancel();
        }
        toast = new Toast(context);
        toast.setDuration(Toast.LENGTH_LONG);
        toast.setView(view);
    }

    public void show() {
        toast.show();
    }


}
